package com.yootk.lifecycle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class YootkBeanPostProcessor implements BeanPostProcessor {
    private static final Logger LOGGER = LoggerFactory.getLogger(YootkBeanPostProcessor.class) ;
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("messageBean".equalsIgnoreCase(beanName)){
            LOGGER.info("【BeanPostProcessor--postProcessBeforeInitialization】{}",bean.getClass().getNestHost());
        }
        return bean ;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if ("messageBean".equalsIgnoreCase(beanName)){
            LOGGER.info("【BeanPostProcessor--postProcessAfterInitialization】{}",bean.getClass().getNestHost());
        }
        return bean ;
    }
}
